<?php
// https://blog.csdn.net/u013252047/article/details/79239871
function quickSort($numbers)
{
    $numbers_len = count($numbers);
    if ($numbers_len <= 1) {
        return $numbers;
    }
    // 基准值
    $selected_number = $numbers[0];
    $lo_numbers = $hi_numbers = array();
    for ($i=1; $i< $numbers_len; $i++) {
        // 小于基准值，存入左边；大于基准值，存入右边
        if ($numbers[$i] > $selected_number) {
            $hi_numbers[] = $numbers[$i];
        } else {
            $lo_numbers[] = $numbers[$i];
        }
    }
    $lo_numbers = quickSort($lo_numbers);
    $hi_numbers = quickSort($hi_numbers);
    return array_merge($lo_numbers, array($selected_number), $hi_numbers);
}
var_dump(quickSort(array(1, 2, 1, 1, 3, 4)));